package com.zjhn.ds.controller.pc;

import com.alibaba.fastjson.JSON;
import com.zjhn.ds.common.BizResult;
import com.zjhn.ds.common.PageResult;
import com.zjhn.ds.domain.dto.pc.GroupDto;
import com.zjhn.ds.domain.dto.pc.SpinnerDto;
import com.zjhn.ds.domain.dto.pc.WorkShopStationDto;
import com.zjhn.ds.param.*;
import com.zjhn.ds.service.GroupService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * @BelongsProject: ds_jlw
 * @BelongsPackage: com.zjhn.ds.controller.pc
 * @Author: sxt
 * @CreateTime: 2023-09-11  10:12
 * @Description: 车间小组接口
 * @Version: 1.0
 */
@Slf4j
@RestController
@RequestMapping("/jlw/group")
@Api(tags = "pc端车间小组接口")
public class GroupController {

    @Resource
    private GroupService groupService;

    @ApiOperation("新增车间小组")
    @PostMapping("/addUpdateGroup")
    public BizResult<?> addUpdateGroup(@RequestBody @Valid AddGroupParam param) {
        log.info("====[INFO]========GroupController====addUpdateGroup param:{}", JSON.toJSONString(param));
        return groupService.addUpdateGroup(param);
    }

    @ApiOperation("删除车间小组")
    @GetMapping("/removeGroup")
    public BizResult<?> removeGroup(@RequestParam("group_id") String groupId) {
        log.info("====[INFO]========GroupController====removeGroup groupId:{}", groupId);
        return groupService.removeGroup(groupId);
    }

    @ApiOperation("按条件分页查询车间小组")
    @PostMapping("/groupPage")
    public BizResult<PageResult<GroupDto>> groupPage(@RequestBody @Valid GroupPageParam param) {
        log.info("====[INFO]========GroupController====groupPage param:{}", JSON.toJSONString(param));
        return groupService.groupPage(param);
    }

    @ApiOperation("分页查询车间小组挡车工")
    @PostMapping("/spinnerPage")
    public BizResult<PageResult<SpinnerDto>> spinnerPage(@RequestBody @Valid GroupRelParam param) {
        log.info("====[INFO]========GroupController====spinnerPage param:{}", JSON.toJSONString(param));
        return groupService.spinnerPage(param);
    }

    @ApiOperation("分页查询车间小组工位")
    @PostMapping("/stationPage")
    public BizResult<PageResult<WorkShopStationDto>> stationPage(@RequestBody @Valid GroupRelParam param) {
        log.info("====[INFO]========GroupController====stationPage param:{}", JSON.toJSONString(param));
        return groupService.stationPage(param);
    }

    @ApiOperation("车间小组批量绑定挡车工或工位")
    @PostMapping("/groupBind")
    public BizResult<?> groupBind(@RequestBody @Valid GroupBindParam param) {
        log.info("====[INFO]========GroupController====groupBind param:{}", JSON.toJSONString(param));
        return groupService.groupBind(param);
    }

    @ApiOperation("车间小组解绑挡车工或工位")
    @PostMapping("/groupUnBind")
    public BizResult<?> groupUnBind(@RequestBody @Valid GroupUnBindParam param) {
        log.info("====[INFO]========GroupController====groupUnBind param:{}", JSON.toJSONString(param));
        return groupService.groupUnBind(param);
    }

}
